package cn.com.dhcc.turbo.web.controller.monitor;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.com.dhcc.app.core.base.BaseController;
import cn.com.dhcc.app.core.service.Log;
import cn.com.dhcc.app.core.service.Log.LOGTYPE;
import cn.com.dhcc.app.pub.core.consts.AppIocBean;
import cn.com.dhcc.turbo.service.queue.QueueService;

@Controller
@RequestMapping("/monitor")
public class QueueMonitorController extends BaseController {
	@SuppressWarnings("deprecation")
	private static Logger logger = Log.getExistLogger(LOGTYPE.SAI);

	@Autowired
	@Qualifier(AppIocBean.TLQ_QUEUE_SERVICE_BEAN)
	private QueueService queueService;

	@RequestMapping(value = "/monitor_sq_list", method = RequestMethod.GET)
	public String sqList(Model model) {
		try {
			model.addAttribute(DATA_KEY, queueService.getSendQueueList());
		} catch (Exception e) {
			logger.error("获取发送队列失败", e);
			return toAlertPage(model, e.getMessage());
		}
		return "monitor/monitor_sq_list";
	}

	@RequestMapping(value = "/monitor_lq_list", method = RequestMethod.GET)
	public String lqList(Model model) {
		try {
			model.addAttribute(DATA_KEY, queueService.getRecvQueueList());
		} catch (Exception e) {
			logger.error("获取接收队列失败", e);
			return toAlertPage(model, e.getMessage());
		}
		return "monitor/monitor_lq_list";
	}
}
